﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Coffee_Controls
{
    public partial class DiagramTable : UserControl
    {
        Point p = new Point();

        public DiagramTable()
        {
            InitializeComponent();

            pnContent.AllowDrop = true;
            pnContent.DragDrop += new DragEventHandler(DiagramTable_DragDrop);
            pnContent.DragEnter += new DragEventHandler(DiagramTable_DragEnter);
            pnContent.AutoScroll = true;
            ///
            MyTable mytable = new MyTable();
            mytable.Location = new Point(0, 0);
            gbTableType.Controls.Add(mytable);
            ///
          
           ///
            comboBoxEdit1.Properties.Items.Add("Thường");
            comboBoxEdit1.Properties.Items.Add("Vip");
            comboBoxEdit1.AllowDrop = true;
            comboBoxEdit1.SelectedIndex = 0;
            comboBoxEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
             
        }

        private void DiagramTable_DragDrop(object sender, DragEventArgs e)
        {
            MyTable table = (MyTable)e.Data.GetData(typeof(MyTable));
            p.X = e.X - this.Parent.Location.X - gbDigramTable.Location.X - gbContent.Location.X- pnContent.Location.X;
            p.Y = e.Y - this.Parent.Location.Y - gbDigramTable.Location.Y - gbContent.Location.Y- pnContent.Location.Y;
            if (!table.Parent.Name.Equals(pnContent.Name))
            {
                MyTable newtable = new MyTable();
                newtable.Location = p;
                pnContent.Controls.Add(newtable);
            }
            else
            {
                table.Location = p;
            }
        }
        private void DiagramTable_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
        }

      

    }
}
